﻿using Microsoft.Extensions.Configuration;

namespace ORMDemo.Core
{
    public class ConfigurationManager
    {
        static ConfigurationManager()
        {
            // 构建配置
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json");
            IConfigurationRoot configuration = builder.Build();
            _SqlConnectionStringWrite = configuration["ConnectionStrings:Write"];
            _SqlConnectionStringRead = configuration.GetSection("ConnectionString").GetSection("Read").GetChildren().Select(s=>s.Value).ToArray();
        }
        private static string _SqlConnectionStringWrite;
        public static string SqlConnectionStringWrite
        {
            get
            {
                return _SqlConnectionStringWrite;
            }
        }
        private static string[] _SqlConnectionStringRead;
        public static string[] SqlConnectionStringRead
        {
            get
            {
                return _SqlConnectionStringRead;
            }
        }
    }
}
